package cn.cas.mango.dto.param.neo4j;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
import org.springframework.data.neo4j.core.schema.TargetNode;

@RelationshipProperties
@Data
@NoArgsConstructor
public class RelationshipEntity {
  @Id
  @GeneratedValue
  private Long id;

  @TargetNode
  private NodeEntity node;

  private Double score;

  private Double transScore(double score) {
    String formattedValue = String.format("%.3f", score);
    return Double.valueOf(formattedValue);
  }

  public RelationshipEntity(NodeEntity node, Double score) {
    this.node = node;
    this.score = transScore(score);
  }
}
